package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.MainClasses;
import org.apache.ibatis.annotations.*;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface MainClassesMapper extends BaseMapper<MainClasses>{
//    @Select("select * from main_classes where main_class_id = #{main_class_id}")
//    MainClasses selectByMainClassId(int main_class_id);
    @Select("select * from main_classes")
    @Results(
            {
                    @Result(column = "main_class_id",property = "mainClassId"),
                    @Result(column = "main_class_name",property = "mainClassName"),
                    @Result(column = "main_class_id",property = "otherClasses",javaType = List.class,
                        many=@Many(select = "com.pro.springbootshop.mapper.OtherClassesMapper.selectByMainClassId")
                    )
            }
    )
    List<MainClasses> selectAllByMain();
    @Select("select * from main_classes where main_class_name=#{mainClassName}")
    MainClasses selectMainClassByName(String mainClassName);
}
